package com.gitee.secretopen.sso.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gitee.secretopen.sso.db.dao.SiteMapper;
import com.gitee.secretopen.sso.db.dao.UserMapper;
import com.gitee.secretopen.sso.db.pojo.Site;
import com.gitee.secretopen.sso.db.pojo.User;
import com.gitee.secretopen.sso.service.DashBoardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 　@description: TODO
 * 　@author secret
 * 　@date 2021/3/17 20:32
 *
 */
@Service
public class DashBoardServiceImpl implements DashBoardService {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private SiteMapper siteMapper;

    /**
     * 查询看板统计数据,用户数、应用数
     * @return
     */
    @Override
    public List<Integer> queryDashBoard() {
        List<Integer> list=new ArrayList<>();
        //查询用户总数
        int userCount=userMapper.selectCount(new QueryWrapper<User>()
                .eq("is_delete",0));
        list.add(userCount);
        int siteCount=siteMapper.selectCount(new QueryWrapper<Site>()
                .eq("is_delete",0));
        list.add(siteCount);
        return list;
    }
}
